/****************************************************
          File Name:gmtime.c
          Author: Abby Cin
          Mail: abbytsing@gmail.com
          Created Time: Mon 11 Aug 2014 10:38:21 AM CST
*****************************************************/

#include<stdio.h>
#include<time.h>

int main()
{
    time_t t, curtime;
    struct tm *gmt;

    curtime=time(&t);
    gmt=gmtime(&curtime);

    fprintf(stdout,"%s\n","Before mktime");
    printf("tm_sec %d\ntm_min %d\ntm_hour %d\ntm_mday %d\ntm_mon %d\n\
            tm_year %d\ntm_wday %d\ntm_yday %d\n",gmt->tm_sec,gmt->tm_min,gmt->tm_hour+8,\
            gmt->tm_mday,gmt->tm_mon+1,gmt->tm_year,gmt->tm_wday,gmt->tm_yday);

    if((curtime=mktime(gmt))==(time_t)(-1))
    {
        perror("mktime");
    }

    fprintf(stdout,"\n%s\n","After mktime");
    printf("the time since 1970 is : %d s\t namely about %d year\n",curtime,curtime/(3600*24*365));
    return 0;
}
